Skip to content

Improve ebauth log parsing, and parse stepup-authentication logs also#558

Open
phavekes wants to merge 3 commits intomainfrom
feature/improve_ebauth_parse_script
Open

Improve ebauth log parsing, and parse stepup-authentication logs also#558
phavekes wants to merge 3 commits intomainfrom
feature/improve_ebauth_parse_script

Conversation

@phavekes
Copy link
Member

@phavekes phavekes commented Nov 4, 2025

No description provided.

@phavekes phavekes requested a review from pmeulen November 4, 2025 11:00
@phavekes phavekes force-pushed the feature/improve_ebauth_parse_script branch from c757189 to c4e408e Compare November 4, 2025 11:50
VALUES (%s, %s)
ON DUPLICATE KEY UPDATE
lastseen = GREATEST(lastseen, VALUES(lastseen))
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

db.commit()
except Exception as e:
db.rollback()
print(f"Error updating last_login for user {user_id}: {e}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

continue

# 1. Filtering condition: Only parse logs having authentication_result:OK
if data.get("authentication_result") != "OK":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only successful authentications are logged, so this check is not necessary. There is currently a bug in the Stepup-Gateway where FAILED is logged, even though the result is OK, making this check do the wrong thing now.

Copy link
Member

@pmeulen pmeulen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filename is strange: parse_stepupauthauth_to_mysql.py.j2 (two times auth)

if data.get("authentication_result") != "OK":
continue

# 2. Extract required fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fields are in a JSON dict "context", not in the top level dict.

E.g. Correct: user_id = data.get("context").("identity_id")

otherwise user_id and timestamp will always be none and nothing will happen.

idp_entity_id = data.get("authenticating_idp")

# Basic data validation
if not user_id or not timestamp:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to know if this fails. Now it fails silently, which means we would miss if this is not working.

loginstamp = parse(timestamp).strftime("%Y-%m-%d %H:%M:%S")
last_login_date = parse(timestamp).strftime("%Y-%m-%d")
except:
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: this fails silently. Not what we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants